﻿@page "/about"
@namespace SwashbucklerDiary.Pages
@inherits PageComponentBase

<MyAppBar Title="@(I18n.T("Mine.About"))"
          OnClick="NavigateToBack">
</MyAppBar>

<ScrollContainer>
    <MCard Class="mb-5 py-sm-3 pl-4"
           Elevation="0"
           Rounded="@("lg")">
        <MList>
            <MListItem>
                <MListItemAvatar Class="mr-8 hidden-xs-only"
                                 Rounded="@("lg")"
                                 Size="75">
                    <MImage Src="./logo/logo.svg"></MImage>
                </MListItemAvatar>
                <MListItemContent>
                    <MListItemTitle Class="text-h5 my-2 font-weight-bold">
                        @(I18n.T("AppName"))
                    </MListItemTitle>
                    <MListItemSubtitle Class="mb-2">
                        version @AppVersion
                    </MListItemSubtitle>
                    <MListItemSubtitle>
                        @(I18n.T("About.Introduction"))
                    </MListItemSubtitle>
                </MListItemContent>
            </MListItem>
        </MList>
    </MCard>

    @foreach (var list in ViewLists)
    {
        <MCard Class="@($"{(ViewLists.Last() != list?"mb-5":"")}")"
               Elevation="0"
               Rounded="@("lg")">
            <MList>
                @foreach (var item in list)
                {
                    <MListItem OnClick="item.OnClick">
                        <MListItemIcon>
                            <MIcon Class="list-item-icon">
                                @(item.Icon)
                            </MIcon>
                        </MListItemIcon>
                        <MListItemContent>
                            @(I18n.T(item.Text))
                        </MListItemContent>
                        <MListItemAction>
                            <MIcon>mdi-chevron-right</MIcon>
                        </MListItemAction>
                    </MListItem>

                    if (list.Last() != item)
                    {
                        <MDivider Class="mx-3"></MDivider>
                    }
                }

            </MList>
        </MCard>
    }

</ScrollContainer>

<MultiDialog @bind-Value="ShowSourceCode"
             Title="@(I18n.T("About.SourceCode.Name"))"
             ListItemModels="CodeSources">

</MultiDialog>

<MMDialog @bind-MyValue="ShowVersionUpdate"
          MaxWidth="420">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("About.Check for updates.Name"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>ShowVersionUpdate=false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="pb-0">
            @(I18n.T("VersionUpdate.Need updates"))
        </MCardText>
        <MCardActions>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="()=>ShowVersionUpdate=false">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="primary"
                     OnClick="ToUpdate">
                @(I18n.T("Share.OK"))
            </MButton>
        </MCardActions>
    </MCard>
</MMDialog>

<SponsorDialog @bind-Value="ShowSponsor" />